package com.liys.authority_liys.controller;

import java.util.Arrays;
import java.util.Map;

import com.liys.authority_liys.commn.PageUtils;
import com.liys.authority_liys.commn.R;
import com.liys.authority_liys.domin.MenuEntity;
import com.liys.authority_liys.service.MenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * 菜单表
 *
 * @author liys
 * @email 303926340@qq.com
 * @date 2021-10-01 18:06:50
 */
@RestController
@RequestMapping("authority_liys/menu")
public class MenuController {
    @Autowired
    private MenuService menuService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    //@RequiresPermissions("authority_liys:menu:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = menuService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
   // @RequiresPermissions("authority_liys:menu:info")
    public R info(@PathVariable("id") Integer id){
		MenuEntity menu = menuService.getById(id);

        return R.ok().put("menu", menu);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    //@RequiresPermissions("authority_liys:menu:save")
    public R save(@RequestBody MenuEntity menu){
		menuService.save(menu);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    //@RequiresPermissions("authority_liys:menu:update")
    public R update(@RequestBody MenuEntity menu){
		menuService.updateById(menu);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    //@RequiresPermissions("authority_liys:menu:delete")
    public R delete(@RequestBody Integer[] ids){
		menuService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
